package com.neusoft.neumooc.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.neusoft.core.common.BaseService;
import com.neusoft.core.common.exception.ServiceException;
import com.neusoft.neumooc.dao.BackContentDAO;
import com.neusoft.neumooc.vo.BackContentVO;

@Service
@Transactional
public class BackContentServiceImpl extends BaseService implements BackContentService {

    @Autowired
    private BackContentDAO backContentDAO;
    
    @Override
    public List<BackContentVO> getContentsByColumnId(String columnId) throws ServiceException {
        try {
            return backContentDAO.getContentsByColumnId(columnId);
        } catch (Exception e) {
            log.error("获取内容列表失败", e);
            throw new ServiceException("获取内容列表失败", e);
        }
    }

    @Override
    public BackContentVO getContentById(String contentId) throws ServiceException {
        try {
            return backContentDAO.getContentById(contentId);
        } catch (Exception e) {
            log.error("获取内容失败", e);
            throw new ServiceException("获取内容失败", e);
        }
    }

    @Override
    public boolean addContent(BackContentVO content) throws ServiceException {
        try {
            return backContentDAO.addContent(content);
        } catch (Exception e) {
            log.error("添加内容失败", e);
            throw new ServiceException("添加内容失败", e);
        }
    }

    @Override
    public boolean updateContent(BackContentVO content) throws ServiceException {
        try {
            return backContentDAO.updateContent(content);
        } catch (Exception e) {
            log.error("更新内容失败", e);
            throw new ServiceException("更新内容失败", e);
        }
    }

    @Override
    public boolean deleteContent(String contentId) throws ServiceException {
        try {
            return backContentDAO.deleteContent(contentId);
        } catch (Exception e) {
            log.error("删除内容失败", e);
            throw new ServiceException("删除内容失败", e);
        }
    }

    @Override
    public boolean updateContentStatus(String contentId, String status) throws ServiceException {
        try {
            return backContentDAO.updateContentStatus(contentId, status);
        } catch (Exception e) {
            log.error("更新内容状态失败", e);
            throw new ServiceException("更新内容状态失败", e);
        }
    }

    @Override
    public List<BackContentVO> searchContents(BackContentVO searchParams) throws ServiceException {
        try {
            return backContentDAO.searchContents(searchParams);
        } catch (Exception e) {
            log.error("搜索内容失败", e);
            throw new ServiceException("搜索内容失败", e);
        }
    }
} 